1. Field of the Invention
The present invention relates generally to maintaining memory affinity. More specifically, the present invention relates to a computer implemented method, data processing system, and computer usable program code for maintaining memory affinity between physical and virtual processors using virtual machine dispatching.
2. Description of the Related Art
Virtualization of computing resources is important in current computer environments. International Business Machine's POWER™ hypervisor, which is part of the firmware in Power 5™ systems, allows the virtualization of physical processors. Hypervisor is a partition management code in the firmware. Virtualization of physical processors is implemented by time-slicing physical processors across the virtual processors. In such an environment, fractional processor allocations enable a greater number of partitions than the number of available physical processors in the system. In addition, each of these partitions may have an arbitrary number of virtual processor systems. This configuration allows an opportunity for any partition to use all the available processors at any time if entitlement is defined as uncapped. Partition entitlement is the amount of time a processor is guaranteed within a dispatch wheel time (time slice). Within the partition, virtual processors run to limits of partitioned entitlement before virtual processors are time-sliced. The “uncapped partition entitlement” allows the partition to use more resources than what the entitlement limit is set. The partition entitlement is evenly distributed amongst the online virtual processors so that the number of online virtual processors impacts the length of each virtual processor's dispatch cycle.
The hypervisor uses the architectural metaphor of a dispatch wheel with a fixed rotation period of a fixed number of milliseconds to guarantee that each virtual processor receives its share of entitlement in a timely fashion. The hypervisor uses a simple scheduling model, where the processor entitlement is distributed with each turn of the hypervisor's dispatch wheel, so each partition is guaranteed a relatively constant stream of service. Entitlement has to be consumed by each partition in a single rotation of the wheel or it is lost. Capacity may be consumed unevenly by the virtual processors in a partition if some of them cede or confer their cycles.
The dispatching and undispatching of virtual processors onto physical processors frequently moves a partition's operating system along with the workloads that are running in it around the system. If the working set memory size is large, then the processor caches are repopulated every time the workload is moved between these processors. If the dispatching frequently changes the mapping of physical to virtual processors, then the cost attributed to cache thrashing will be heavy.
To minimize the cache overhead, the hypervisor needs to maintain the physical and virtual processor affinity while dispatching them. However, the two goals of achieving maximum utilization through virtualization and maintaining physical to virtual processor affinity are in direct conflict with each other. When a processor becomes idle to maximize its utilization, the virtual processor needs to be assigned to the idle processor whether the idle processor ran virtual processor last or not. To maintain affinity, if the free virtual processor is not the last ran virtual processor, then deferring dispatching until the last ran virtual processor becomes free will end up wasting the central processing unit cycles. Finding the fine line between these conflicting requirements needs much more complex algorithm that takes into account many other factors that are part of the micro-partitioned environment.
The POWER™ hypervisor maintains four states in its central processing unit resource management or dispatching state engine. The states include wait, frozen, free, and run. When a physical processor is undispatched from a virtual processor, the virtual processor goes into wait state. If the virtual processor has used its entitlement, the virtual processor goes into frozen state until the next dispatch wheel time starts. The virtual processor moves from the wait state to the free state once the wait time is over. The POWER™ hypervisor selects the virtual processor to dispatch from the free virtual processor pool. When a physical processor becomes free, the hypervisor assigns it to a virtual processor from the free pool. In this selection process, the hypervisor tries to maintain processor affinity, that is, it checks to see if the physical processor is mapped to a specific virtual processor of a specific partition in the preceding time. However, it is not always possible to find the one processor that was mapped in the preceding time as the number of physical processors are fewer than the number of virtual processors, and idle cycles of a virtual processor are ceded to other virtual processors. Thus, a need exists to improve the chances of processor affinity.